package com.qq.mobilemanager.activity;

import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qq.mobilesafe.R;
import com.qq.mobilesafe.view.SettingItemView;

public class Setup2Activity extends BaseSetupActivity {
	
	@ViewInject(R.id.siv_sim)
	private SettingItemView siv_sim;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setup2);
		ViewUtils.inject(this);
		String sim = sp.getString("sim", null);
		if (!TextUtils.isEmpty(sim)) {
			siv_sim.setChecked(true);
		}else {
			siv_sim.setChecked(false);
		}
		
		
		siv_sim.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if (siv_sim.isChecked()) {
					siv_sim.setChecked(false);
					sp.edit().remove("sim").commit();
					
				}else {
					siv_sim.setChecked(false);
					
					TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
					String simSerialNumber = tm.getSimSerialNumber();
					sp.edit().putString("sim", simSerialNumber).commit();
				}
			}
		});
		
	}
	
	
	
	public void showNextPage(){
		startActivity(new Intent(this,Setup3Activity.class));
		finish();
		
		overridePendingTransition(R.anim.tran_in, R.anim.tran_out);
	}
	
	public void showPreviousPage(){
		startActivity(new Intent(this,Setup1Activity.class));
		finish();
		
		overridePendingTransition(R.anim.tran_previous_in, R.anim.tran_previous_out);
	}
	
	

}
